package bit.project.controller;

import bit.project.common.AppResult;
import bit.project.exception.ApplicationException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Api(tags = "测试接口")
@RestController
@RequestMapping("/test")
public class Testcontroller {
    @ApiOperation("测试打印")
    @GetMapping("/hello")
    public String hello(){
        return "hello,spring boot";
    }
    @ApiOperation("测试异常")
    @GetMapping("/exception")
    public AppResult testException() throws Exception {
        throw new Exception("这是一个Exception.....");
    }
    @GetMapping("/applicationException")
    public AppResult testApplicationException()throws ApplicationException{
        throw new ApplicationException("这是一个ApplicationException.....");
    }
    @ApiOperation("测试传参")
    @GetMapping("/helloByName")
    public  String testHelloByName(@ApiParam("传入名字") String name){
        return "hello," + name;
    }

}
